package com.huiyujiaoyu.util;

import android.os.CountDownTimer;

/**
 * 计时器
 * Created by zhuzichun on 2016/4/15.
 */
public class TimeDownTool extends CountDownTimer {
    OnTimeDownListener listener;

    public TimeDownTool(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }

    @Override
    public void onFinish() {
        if(listener!=null)
            listener.onFinish();
    }

    @Override
    public void onTick(long millisUntilFinished) {
        if(listener!=null)
            listener.onTick(millisUntilFinished);
    }

    public void setOnTimeDownListener(OnTimeDownListener listener){
        this.listener = listener;
    }

    public interface OnTimeDownListener{
        void onFinish();
        void onTick(long millisUntilFinished);
    }
}
